#pragma once
//数据库类,用于管理数据表等,
//支持的数据库类别列表：Mysql SQLite

#include "msql_global.h"
#include "MSqlTable.h"

namespace NsMSql
{
	class MSqlServer;
	class MSqlConnectionPool;
}

namespace NsMSql
{
	class MSQL_EXPORT MSqlDatabase
	{
	public:
		MSqlDatabase(const MSqlServerAttr& sqlServerAttr);
		~MSqlDatabase();
	private:
		//删除数据库
		bool drop();
	public:
		//创建表
		bool createTable(const QString& tableName, const QList<MTableField>& tableFields);
		//删除表
		bool dropTable(const QString& tableName);
	public:
		//获取数据库服务器属性
		MSqlServerAttr getSqlServerAttr();
		//获取连接池
		MSqlConnectionPool* getSqlConnectionPool();
	private:
		MSqlServerAttr m_sqlServerAttr;
		MSqlConnectionPool* m_pSqlConnectionPool;
		QMap<QString, MSqlTable*> m_nameToSqlTableMap;		//<表名，表对象>

		friend class MSqlServer;
	};
}

